<?php
/*
 * This is payment page.
 */
include '../config.php';
include '../head.php';
session_start();
/*
 * paypal
 */
$paypal_page = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
$seller_id = 'sjk.fr_1346599808_biz@gmail.com';
$return_address = 'http://' . $_SERVER['HTTP_HOST'] . '/salusmain/baby/success.php';
$return_cancle = 'http://' . $_SERVER['HTTP_HOST'] . '/salusmain/baby/cancle.php';



$type = $_POST['type'];
if ($type == 'seller') {
    $pro_detail_id = $_SESSION['proid'];
 $dis = $_SESSION['discount'];
} elseif ($type == 'direct') {
    $pro_detail_id = $_POST['pro_de_id'];
}

$d1 = mysql_query("select * from salus_buy_detail where id= '$pro_detail_id' ") or die(mysql_error());
while ($row = mysql_fetch_array($d1)) {
    $year = $row['product_year'];
    $prize = $row['product_prize'];    
}

if ($type == 'seller') {
    $disc = $dis / 100;
    $buy = mysql_query("select * from salus_buy_detail where id = '$pro_detail_id' ") or die(mysql_error());
    while ($row1 = mysql_fetch_array($buy)) {
        $maincost = $row1[3];
        $dis1 = $maincost * $disc;
        $pad = $maincost - $dis1;
        $pad = $pad / 2;
    }
    $amount = $pad;
}else{
    $amount = $prize;
}

$_SESSION['amounts'] = $amount;
?>
<title>Payment Gateway</title>
<?php include '../header_profile_baby.php'; ?>
<body>
    <div id="wrapper">
        <div id="mainContent">
            <div id="class" style="border: 1px #000000 dotted ; width: 600px; margin-left: 30%; ">
                <center><h1>PAYMENT GATEWAY <br/><img src="http://<?= $_SERVER['HTTP_HOST'] ?>/salusbaby/include/images/me.png" height="100px;" /> </h1></center><hr>
                Your Subscription Details :<br>
                Year : <b><?=$year?></b><br/>
                Amount : <b><?=$amount?> &euro;</b><hr>
                <form action=<?= $paypal_page ?> method="post" >
                    <input type= "hidden" name="cmd" value = "_xclick" />
                    <input type="hidden" name="business" value="<?= $seller_id ?>" />
                    <input type="hidden" name="item_name" value="SalusMe" />
                    <input type="hidden" name="item_number" value="<?=$pro_detail_id?>" />
                    <input type="hidden" name="buy_detail_id" value="<?=$pro_detail_id?>" />
                    <input type="hidden" name="amount" value="<?= $amount ?>" />
                    <input type="hidden" name="no_shipping" value="1" />
                    <input type="hidden" name="no_note" value="1" />
                    <input type="hidden" name="currency_code" value="EUR" />
                    <input type="hidden" name="bn" value="PP-BuyNowBF" />
                    <input type='hidden' name='return' value="<?= $return_address ?>" />
                    <input type='hidden' name='cancel_return' value="<?= $return_cancle ?>" />                    
                    <input type="image" src="../button_07.gif" name="submit" />
                </form>
            </div>
        </div>
    </div>
</body>